/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.inventory.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author sithum
 */
@Entity
@Table(name = "CUSTOMER", catalog = "", schema = "APP")
@NamedQueries({@NamedQuery(name = "Customer.findAll", query = "SELECT c FROM Customer c"), @NamedQuery(name = "Customer.findByCustomerId", query = "SELECT c FROM Customer c WHERE c.customerId = :customerId"), @NamedQuery(name = "Customer.findByCustomerName", query = "SELECT c FROM Customer c WHERE c.customerName = :customerName"), @NamedQuery(name = "Customer.findByShopName", query = "SELECT c FROM Customer c WHERE c.shopName = :shopName"), @NamedQuery(name = "Customer.findByDiscountPercentage", query = "SELECT c FROM Customer c WHERE c.discountPercentage = :discountPercentage"), @NamedQuery(name = "Customer.findByDiscountAmount", query = "SELECT c FROM Customer c WHERE c.discountAmount = :discountAmount"),
    @NamedQuery(name = "Customer.recordCount", query = "SELECT COUNT(c) FROM Customer c")})
public class Customer implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "CUSTOMER_ID", nullable = false)
    private Integer customerId;
    @Basic(optional = false)
    @Column(name = "CUSTOMER_NAME", nullable = false, length = 50)
    private String customerName;
    @Basic(optional = false)
    @Column(name = "SHOP_NAME", nullable = false, length = 50)
    private String shopName;
    @Column(name = "DISCOUNT_PERCENTAGE", precision = 8, scale = 2)
    private BigDecimal discountPercentage;
    @Column(name = "DISCOUNT_AMOUNT", precision = 8, scale = 2)
    private BigDecimal discountAmount;
    @OneToMany(mappedBy = "customerId", fetch=FetchType.EAGER, cascade={CascadeType.ALL})
    private List<CustomerDetails> customerDetailsCollection;
    @OneToMany(mappedBy = "customerId", fetch=FetchType.EAGER, cascade={CascadeType.ALL})
    private List<Invoice> invoiceCollection;

    public Customer() {
    }

    public Customer(Integer customerId) {
        this.customerId = customerId;
    }

    public Customer(Integer customerId, String customerName, String shopName) {
        this.customerId = customerId;
        this.customerName = customerName;
        this.shopName = shopName;
    }

    public Integer getCustomerId() {
        return customerId;
    }

    public void setCustomerId(Integer customerId) {
        this.customerId = customerId;
    }

    public String getCustomerName() {
        return customerName;
    }

    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }

    public String getShopName() {
        return shopName;
    }

    public void setShopName(String shopName) {
        this.shopName = shopName;
    }

    public BigDecimal getDiscountPercentage() {
        return discountPercentage;
    }

    public void setDiscountPercentage(BigDecimal discountPercentage) {
        this.discountPercentage = discountPercentage;
    }

    public BigDecimal getDiscountAmount() {
        return discountAmount;
    }

    public void setDiscountAmount(BigDecimal discountAmount) {
        this.discountAmount = discountAmount;
    }

    public List<CustomerDetails> getCustomerDetailsCollection() {
        return customerDetailsCollection;
    }

    public void setCustomerDetailsCollection(List<CustomerDetails> customerDetailsCollection) {
        this.customerDetailsCollection = customerDetailsCollection;
    }

    public List<Invoice> getInvoiceCollection() {
        return invoiceCollection;
    }

    public void setInvoiceCollection(List<Invoice> invoiceCollection) {
        this.invoiceCollection = invoiceCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (customerId != null ? customerId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Customer)) {
            return false;
        }
        Customer other = (Customer) object;
        if ((this.customerId == null && other.customerId != null) || (this.customerId != null && !this.customerId.equals(other.customerId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.inventory.entities.Customer[customerId=" + customerId + "]";
    }
}
